<template>
	<view class="newActivePage">
		<image :src="activeBg" class="image" @click="receiveLimitFree"></image>
	</view>
</template>

<script>
	import api from '@/api/index.js';
	export default {
		data() {
			return {
				activeBg: null,
				date: '',
			}
		},
		onLoad(options) {
			if (options && options.date) {
				this.date = options.date
			}
			this.getFreeActive()
		},
		methods: {
			//领取新人免单券
			receiveLimitFree() {
				api.receiveLimitFree({
					date:this.date
				}).then(res => {
					uni.showToast({
						title: "领取成功"
					})
					setTimeout(() => {
						uni.navigateBack({
							delta: 1
						})
					}, 1500)
				})
			},
			getFreeActive() {
				api.getFreeActive().then(res => {
					this.activeBg = res.data.seckill_bg
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.newActivePage {
		position: relative;
		width: 100%;
		height: 100vh;
		overflow: hidden;

		.image {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			object-fit: cover;
		}
	}
</style>